/**
 * Copyright &copy; 2016-2022 <a href="http://www.xxxx.com">xxxx</a> All rights reserved.
 */
package com.channelsharing.hongqu.portal.api.service.impl;

import com.channelsharing.common.service.CrudServiceImpl;
import com.channelsharing.hongqu.portal.api.constant.Constant;
import com.channelsharing.hongqu.portal.api.dao.BannerDao;
import com.channelsharing.hongqu.portal.api.entity.Banner;
import com.channelsharing.hongqu.portal.api.service.BannerService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 轮播Service
 *
 * @author xaioemo
 * @version 2019-03-22
 */
@Transactional(readOnly = true)
@Service
public class BannerServiceImpl extends CrudServiceImpl<BannerDao, Banner> implements BannerService {
    @Resource
    private BannerDao bannerDao;
    public static final String PORTAL_CACHE_PREFIX = Constant.PORTAL_CACHE_PREFIX;
    @Override
    public Banner findOne(Long id) {
        Banner entity = new Banner();
        entity.setId(id);
        return super.findOne(entity);
    }

    @Override
    @CacheEvict(value = PORTAL_CACHE_PREFIX
            + "banner", key = "#root.target.PORTAL_CACHE_PREFIX + 'banners' ")
    public List<Banner> findBanners() {
        return bannerDao.findBanners();
    }
}
